import simplejson as json
import base64
import urllib2
import urllib
class Twitter:
	"""Twitter function library"""
	
	API_URL = "https://twitter.com"
	
	def __init__(self, username="", password=""):
		"""initializing the username and password"""
		
		self.username = username
		self.password = password
		
		self.__authStr = base64.b64encode(self.username + ":" + self.password)
	
	def getFriends(self, name, cursor = -1):
		url = self.API_URL + ("/statuses/friends/%s.json?cursor=%s" % (name, str(cursor)) )
		req = urllib2.Request(url)
		
		try:
			response = urllib2.urlopen(req)
			result = response.read()
		except urllib2.URLError, e:
			return e.code
		
		return json.loads(result)
	